package com.example.tool.activtiy;

import android.content.Intent;
import android.support.v7.widget.CardView;
import android.view.View;
import android.widget.TextView;

import com.example.tool.R;
import com.example.tool.activtiy.base.BaseActivity;
import com.example.tool.mvp.CommonPresent;

import butterknife.BindView;
import butterknife.OnClick;

import static com.example.tool.activtiy.PopStyleActivity.TransitionMode.BOTTOM;
import static com.example.tool.activtiy.PopStyleActivity.TransitionMode.FADE;
import static com.example.tool.activtiy.PopStyleActivity.TransitionMode.LEFT;
import static com.example.tool.activtiy.PopStyleActivity.TransitionMode.RIGHT;
import static com.example.tool.activtiy.PopStyleActivity.TransitionMode.SCALE;
import static com.example.tool.activtiy.PopStyleActivity.TransitionMode.TOP;

/**
 * Created Date 2019/8/27
 *
 * @author liangkun
 * description：activtiy弹窗跳转样式
 */
public class PopStyleActivity extends BaseActivity<CommonPresent> {
    @BindView(R.id.card_home_one)
    protected CardView button;
    @BindView(R.id.tv_title)
    protected TextView tvTitle;
    public enum TransitionMode {LEFT, RIGHT, TOP, BOTTOM, SCALE, FADE}
    @Override
    protected int getLayoutId() {
        return R.layout.activity_transition;
    }

    @Override
    protected void initView() {
//        ivGb.setImageResource(R.mipmap.bg);
        tvTitle.setText("activtiy跳转样式");
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initEvent() {
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(PopStyleActivity.this, BottomActivity.class));

            }
        });

    }

    @OnClick({R.id.card_home_left, R.id.card_home_right, R.id.card_home_top,
            R.id.card_home_bottom, R.id.card_home_scale, R.id.card_home_fade})
    protected void Onclick(View view) {
        startActivity(new Intent(PopStyleActivity.this, CommonActivity.class));
        switch (view.getId()) {
            case R.id.card_home_left:
                selectType(LEFT);
                break;
            case R.id.card_home_right:
                selectType(RIGHT);

                break;
            case R.id.card_home_top:
                selectType(TOP);

                break;
            case R.id.card_home_bottom:
                selectType(BOTTOM);
                break;
            case R.id.card_home_scale:
                selectType(SCALE);
                break;
            case R.id.card_home_fade:
                selectType(FADE);
                break;

        }
    }

    @Override
    protected CommonPresent createPresenter() {
        return null;
    }

    /**
     * 选择动画
     *
     * @param type
     */
    public void selectType(TransitionMode type) {

        switch (type) {
            case LEFT:
                overridePendingTransition(R.anim.activity_left_in, R.anim.activity_left_out);
                break;
            case RIGHT:
                overridePendingTransition(R.anim.activity_right_in, R.anim.activity_right_out);
                break;
            case TOP:
                overridePendingTransition(R.anim.activity_top_in, R.anim.activity_top_out);
                break;
            case BOTTOM:
                overridePendingTransition(R.anim.activity_translate_bottom_in, R.anim.activity_translate_bottom_out);
                break;
            case SCALE:
                overridePendingTransition(R.anim.activity_scale_in, R.anim.activity_scale_out);
                break;
            case FADE:
                overridePendingTransition(R.anim.activity_fade_in, R.anim.activity_fade_in);
                break;

        }
    }

    /**
     * Android的开发过程中，屏幕的坐标定义为：左上角为原点(0,0) ，水平向右为X正半轴，竖直向下为Y正半轴，而Activity的原点坐标(0，0)也是位于左上角；
     *
     * 当Activity从屏幕的右侧进入屏幕的过程，相当于Activity的X坐标由100%p到0的过程（见下图灰色示意部分，对应文件push_left_in.xml）；
     *
     * 当Activity从屏幕的左侧进入屏幕的过程，相当于Activity的X坐标由－100%p到0的过程；（见下图粉色示意部分，对应文件push_right_in.xml）；
     *
     * 当Activity从屏幕的右侧移出屏幕的过程，相当于Activity的X坐标由0到100%p的过程；（见下图红色示意部分，对应文件push_left_out.xml）；
     *
     * 当Activity从屏幕的左侧移出屏幕的过程，相当于Activity的X坐标由0到－100%p的过程；（见下图绿色示意部分，对应文件push_right_out.xml）；
     * ————————————————
     * 原文链接：https://blog.csdn.net/tianmaxingkong_/article/details/50085059
     */
}
